--#############WEB Services
if object_id('spComisionPersonal', 'p') is not null
drop procedure spGenerarSerieDocumento
go
create procedure spGenerarSerieDocumento(
@sucursal_id int,
@comprobante_id int,
@PKCreado int output)
as begin
	declare @serie int, @numero int
	select @serie=comSer_serie, @numero=max(comSer_numero+1) from comprobanteSerie 
	where sucursal_id=@sucursal_id and comprobante_id=@comprobante_id and comSer_estado='a'
	group by comSer_serie
	
	insert into comprobanteSerie(comSer_serie,comSer_numero,comprobante_id,sucursal_id,comSer_estado)
	values (@serie,@numero,@comprobante_id,@sucursal_id,'a')
	set @PKCreado=@@IDENTITY 
end
go

select P. from VE_vendedorComision VC, VE_vendedor V, PL_personal P